/*
 * Color.java
 *
 * Created on 2004/01/05 +0900
 *
 * $Revision: 58 $
 * $Date: 2008-12-06 08:59:45 +0000 (Sat, 06 Dec 2008) $
 */

package org.gikolet.framework.ui;

/**
 * @author Tetsutaro (latest modification by $Author: tetsutaro.ss $)
 * @version $Revision: 58 $ $Date: 2008-12-06 08:59:45 +0000 (Sat, 06 Dec 2008) $
 */
public class Color {
    public static final Color WHITE = new Color(0x0ffffff);
    public static final Color LIGHT_GRAY = new Color(0x0c0c0c0);
    public static final Color GRAY = new Color(0x0808080);
    public static final Color DARKGRAY = new Color(0x0404040);
    public static final Color BLACK = new Color(0x0000000);
    public static final Color RED = new Color(0x0ff0000);
    public static final Color PINK = new Color(0x0ffafaf);
    public static final Color ORANGE = new Color(0x0ffc800);
    public static final Color YELLOW = new Color(0x0ffff00);
    public static final Color GREEN = new Color(0x000ff00);
    public static final Color MAGENTA = new Color(0x0ff00ff);
    public static final Color CYAN = new Color(0x000ffff);
    public static final Color BLUE = new Color(0x00000ff);

    public static final Color BACK_COLOR = new Color(0x0ECE4D8);
    public static final Color FORE_COLOR = new Color(0x0000000);
    public static final Color SELECTION_BACK_COLOR = new Color(0x0316ac5);
    public static final Color SELECTION_FORE_COLOR = new Color(0x0ffffff);

    private int rgb;

    public Color(int rgb) {
	this.rgb = rgb;
    }

    public Color(int r, int g, int b) {
	this.rgb = (r << 16) + (g << 8) + (b);
    }

    public int getBlue() {
	return this.rgb & 255;
    }

    public int getGreen() {
	return (this.rgb >> 8) & 255;
    }

    public int getRed() {
	return (this.rgb >> 16) & 255;
    }

    public int getRGB() {
	return this.rgb;
    }

    public Color getReversalColor() {
	return new Color(255 - getRed(), 255 - getGreen(), 255 - getBlue());
    }

    public int hashCode() {
	return this.rgb;
    }

    public boolean equals(Object obj) {
	if (obj instanceof Color) {
	    return equals((Color) obj);
	}
	return false;
    }

    public boolean equals(Color color) {
	if (color != null && this.rgb == ((Color) color).rgb) {
	    return true;
	}
	return false;
    }
}
